<?php
namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
// use app\project;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    protected $table = 'users';
    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    // 项目函数
    public function projects(){
        // 取得用户模型的实例，$user->projects();获取该用户下的项目
        return $this->hasMany('App\project');
        // return $this->hasMany(project::class);

    }

    // 用户和task的关系，是通过project间接拥有task
    public function tasks(){
        // 取得用户模型的实例，$user->projects();获取该用户下的项目
        return $this->hasManyThrough('App\task','App\project');
        // return $this->hasMany(project::class);

    }
}
